<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    
	
	<title>_调拨入库登记</title>
	<script type="text/javascript">
	
        $(function() {
		    $("#queryForm").validate(); 
		    $("#inputForm").validate(); //为inputForm注册validate函数
			$("#_fromDate").datepicker({ format : 'yyyy-mm-dd' });
			$("#_toDate").datepicker({ format : 'yyyy-mm-dd' });
       });
       
	  function mySubmit(){
 		   if( $("#inputForm").valid() ){
 		      $("#submit_btn").attr("disabled","disabled");
 		      $("#inputForm").submit();
 		   }
 	  }
 	  
 	  function login(billId){
 	      $.ajax({
				   type : 'post',
					url : '${ctx}/instorageBill/ajaxGetBill',
					data : {
						billId:billId
					},
					dataType : 'json',
					success : function(data) {
					
						$("#outCode").val(data.outCode);
						$("#outstorageCode").val(data.outstorage.groupName);
						$("#areagroupCode").val(data.areagroup.groupName);
						
						$("#boxNum").val(data.boxNum);
						$("#skuNum").val(data.skuNum);
						$("#goodsNum").val(data.goodsNum);
						$("#billId").val(data.id);
						
					},
					error : function() {
						alert("网络繁忙，请稍后重试...");
					}
				}); 
 	     
 	     
 	     
 	     
 	     
 	     
 	  }
	  
    </script>
</head>

<body>
    <c:if test="${not empty message}">
		<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
	</c:if>
	
	<div style="height: 10px;"></div>
	
	<div class="row">
		<div class="span12" style="margin-left: 20px;">
			<form class="form-search" id="queryForm" action="${ctx}/instorageBill/list_allot" method="post">
			
				<label style="margin-left:10px;">入库网点：</label> 
				<select  name="_areagroupCode"  id="_areagroupCode" value="${param._areagroupCode}"  class="input-medium">
					<option value=""></option>
					<c:forEach items="${areagroupList}" var="areagroup">
						<option value="${areagroup.groupCode}"
						<c:if test="${param._areagroupCode eq areagroup.groupCode}">selected=selected</c:if>
						>${areagroup.groupName}</option>
					</c:forEach>
				</select>
				
				<label style="margin-left:10px;">入库单状态：</label> 
				<select  name="_status"  id="_status" value="${_status}"  class="input-medium">
					<option value="" <c:if test="${_status eq ''}">selected=selected</c:if> ></option>
					<option value="0" <c:if test="${_status eq '0'}">selected=selected</c:if> >未登记</option>
				    <option value="1" <c:if test="${_status eq '1'}">selected=selected</c:if> >已登记</option>
				    <option value="2" <c:if test="${_status eq '2'}">selected=selected</c:if> >已点收</option>
				    <option value="3" <c:if test="${_status eq '3'}">selected=selected</c:if> >审核通过</option>
				    <option value="4" <c:if test="${_status eq '4'}">selected=selected</c:if> >审核驳回</option>
				    <option value="5" <c:if test="${_status eq '5'}">selected=selected</c:if> >任务执行中</option>
				    <option value="6" <c:if test="${_status eq '6'}">selected=selected</c:if> >完成所有任务</option>
				</select>
				
				<label>&nbsp;&nbsp;&nbsp;入库日期&nbsp;&nbsp;&nbsp;从：</label> 
			 	<input type="text" name="_fromDate" id="_fromDate"  class="input-medium " value="${_fromDate}" style="margin-left: -10px;"> 
			 	<label>至：</label> 
			 	<input type="text" name="_toDate" id="_toDate" class="input-medium " value="${_toDate}" style="margin-left: -10px;"> 
			 	
			    <button type="submit" class="btn" style="margin-left: 10px;">搜索</button>
		    </form>
	    </div>
	</div>
	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
		    <th style="width: 80px;">入库类型</th>
		    <th style="width: 80px;">出货仓库</th>
		    <th style="width: 100px;">出库单号</th>
		    <th style="width: 80px;">入库网点</th>
		    <th style="width: 80px;">箱子数量</th>
			<th style="width: 80px;">SKU数量</th>
			<th style="width: 80px;">商品数量</th>
		    <th style="width: 180px;">入库单号</th>
			<th style="width: 150px;">入库时间</th>
			<th style="width: 100px;">登记人</th>
			<th style="width: 80px;">当前状态</th>
			<th style="width: 150px;">管理</th>
		</tr></thead>
		<tbody>
		<c:forEach items="${page.content}" var="bill">
			<tr>
			     <td>
			      <c:if test="${bill.billType eq '1' }">总仓入库</c:if>
			      <c:if test="${bill.billType eq '2' }">调拨入库</c:if>
			    </td>
			    <td>${bill.outstorage.groupName}</td>
			    <td>${bill.outCode}</td>
			    <td>${bill.areagroup.groupName}</td>
			    <td>${bill.boxNum}</td>
			    <td>${bill.skuNum}</td>
			    <td>${bill.goodsNum}</td>
			    <td>${bill.instorageCode}</td>
			    <td>${fn:substring(bill.inTime,0,19)}</td>
			    <td>${bill.creater.realname}</td>
			    <td>
			       <c:if test="${bill.status eq '0' }">未登记</c:if>
			        <c:if test="${bill.status eq '1' }">已登记</c:if>
			       <c:if test="${bill.status eq '2' }">已点收</c:if>
			       <c:if test="${bill.status eq '3' }">审核通过</c:if>
			       <c:if test="${bill.status eq '4' }">审核不通过</c:if>
			       <c:if test="${bill.status eq '5' }">任务执行中</c:if>
			       <c:if test="${bill.status eq '6' }">上架完成</c:if>
			    </td>
				<td>
				   <c:if test="${bill.status eq '0'}">
				        <a href="#detail" data-toggle="modal" class="btn btn-primary" onclick="login('${bill.id}');">登记</a>
				   </c:if>
					<c:if test="${bill.status ne '0'}">
				        <input type="button" class="btn" disabled="disabled"  value="登记"/>
				   </c:if>
				     <a href="" data-toggle="modal" class="btn" onclick="return false;">查看</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
	<tags:pagination page="${page}" paginationSize="5"/>
	
	
	<!-- 添加/修改入库单 -------------------------------------------------------------------------------------------------->
	<div style="display: none; width:880px;" class="modal hide fade"  id="detail" >
	<form id="inputForm"  method="post" class="form-horizontal" action="${ctx}/instorageBill/allotLogin">
	
		<!-- 头 -->
		<div class="modal-header" style="height: 20px; vertical-align: middle; " >
		<span style="font-size: large; font-weight: bold;" id="windowTitle"></span>
		</div>
		<!-- 体 -->
		<div class="modal-body" style="height: 300px;">
						<fieldset>
						      <input type="hidden" id="billId" name="billId"/>
						      
							  <!-- 行1 -->
						      <div class="row" >
						             <div class="span4" style="margin-left: -80px;">
											<div class="control-group">
												<label  class="control-label" >出库单号:</label>
												<div class="controls" >
												<input type="text" id="outCode" name="outCode"  style="margin-left: -10px; width: 188px;" disabled="disabled">
												</div>
											</div>
							          </div>
							          
							          <div class="span4" >
											<div class="control-group">
												<label  class="control-label" style="margin-left:-10px;">出库网点:</label>
												<div class="controls">
													<input type="text" id="outstorageCode" name="outstorageCode"   style="margin-left: -20px; width: 188px;" disabled="disabled">
											</div>
							          </div>
							           </div>
							          
							           <div class="span4" >
											<div class="control-group">
												<label  class="control-label" style="margin-left:-20px;" >入库网点:</label>
												<div class="controls">
													<input type="text" id="areagroupCode" name="areagroupCode"  style="margin-left: -30px; width: 188px;" disabled="disabled">
												</div>
											</div>
							          </div>
							          
						       </div>
						       
						        <!-- 行2 -->
							   <div class="row" >
							   			<div class="span4" style="margin-left: -80px;">
									      	    <div class="control-group">
													<label  class="control-label">箱子数量:</label>
													<div class="controls">
													   <input type="text" id="boxNum" name="boxNum"  class="digits" style="margin-left: -10px; width: 188px;">
													</div>
											   </div>
								         </div>
								         <div class="span4">
								      	    <div class="control-group">
												<label  class="control-label" style="margin-left:-10px;">SKU数量:</label>
												<div class="controls">
													 <input type="text" id="skuNum" name="skuNum"  class="digits" style="margin-left: -20px; width: 188px;">
												</div>
											</div>
								      	 </div>
								      	 <div class="span4">
								      	   <div class="control-group">
												<label  class="control-label" style="margin-left:-20px;">商品数量:</label>
												<div class="controls">
												    <input type="text" id="goodsNum" name="goodsNum"  class="digits" style="margin-left: -30px; width: 188px;">
												</div>
											</div>
								         </div>
							       </div>   
							       
						      <!-- 行3 -->
						      <div class="row" >
						             
									 <div class="span12" style="margin-left: -80px;">
							      	    <div class="control-group">
											<label  class="control-label" style="margin-left:0px;">备注信息:</label>
											<div class="controls">
												<textarea rows="4" id="remarks" name="remarks" class="requires" style="width: 760px; height:118px; margin-left: -10px;" maxlength="100"></textarea>
											</div>
										</div>
						              </div>
							      	  
						     </div> 
						     
							</fieldset>	      
		      
		</div>
		<!-- 尾 -->
		<div class="modal-footer">
			<input id="submit_btn" class="btn btn-primary"  type="button" value="提交" onclick="mySubmit();"/>&nbsp;	
			<input id="cancel_btn" class="btn" type="button" value="返回" data-dismiss="modal" aria-hidden="true"/>
			<input type="reset" style="display:none;" /> 
		</div>
		
        </form> 
     </div>
     <!------------------------------------------------------------------------------------------------------------->
	
</body>
</html>
